var figure = document.querySelector(".figure");
var dian = document.querySelectorAll(".dian>li");
var num = -100;
figure.style.marginLeft = num + "%" ;
var x;
var _x;
var aa;
var ll;
var _width = window.screen.availWidth;
console.log(_width);
// var timer;
function fn(){
    setInterval( function() {
        if( figure.style.marginLeft >= "-500%" ) {
            figure.style.transition = "all 0s";
            num = -100;
            figure.style.marginLeft = num + "%" ;
        }else {
            figure.style.transition = "all 2s";
            figure.style.marginLeft = num + "%";
        }
        num+=-100;
        var nn = -num/100-2;
        if(nn>=4) {
            nn=0;
            dian[3].classList.remove("active");
        }
        dian[nn].classList = "active";
        console.log(nn);
        for(var i = 0; i < nn; i++){
            dian[i].classList.remove("active");
        }
        
        
    }, 2000);
}
fn()

// figure.ontouchstart = function(){
//     x = event.changedTouches[0].clientX;
//     timer == null;

    
//     figure.ontouchend = function(){
//         fn()
//         _x = event.changedTouches[0].clientX;
//         aa = x - _x ;
//         console.log(aa);
//         if( aa >= 0 ) {
//             num += -100;
//             figure.style.marginLeft = num + "%" ;
//         }else {
//             num += 100;
//             figure.style.marginLeft = num + "%" ;
//         }
//         console.log(num);
//     }
// }
var sho = document.querySelector(".sho");
var input = document.querySelector(".sho>.search>input");
var div = document.querySelector(".sho>.for>div");
var p = document.querySelector(".sho>.for>p");
window.onscroll = function(){ 
    console.log(11);
    var scrollTop = document.documentElement.scrollTop;
    console.log(scrollTop);
    if(scrollTop <= 0) {
        sho.style.backgroundColor = "";
        input.style.backgroundColor = "white";
        div.style.backgroundPosition = "0 -52px";
        p.style.color = "white";

    }else {
        sho.style.backgroundColor = "white";
        input.style.backgroundColor = "#ccc";
        div.style.backgroundPosition = "0 -112px";
        
        p.style.color = "black";
    }
}

